using UnityEngine;

namespace FrameworkBase.Example
{
    public interface ICanSayHello
    {
        void SayHello();
        void SayOther();
    }
    
    public class InterfaceDesignExample : MonoBehaviour, ICanSayHello
    {
        /// <summary>
        /// 接口的隐式实现
        /// </summary>
        public void SayHello()
        {
            Debug.Log("Hello");
        }
        
        /// <summary>
        /// 接口的显式实现
        /// </summary>
        void ICanSayHello.SayOther()
        {
            Debug.Log("Other");
        }

        private void Start()
        {
            this.SayHello();

            (this as ICanSayHello).SayOther(); // 显式实现的接口必需将对象显式转换为对应的接口类型才可以调用
        }
    }
}
